package DAO.MySQL;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import Model.RankBean;
import Model.RankListBean;

public class RankListDAOImpl
	extends GenericDAO<RankListBean>
	implements DAO.RankListDAO
{
	@Override
	protected RankListBean parseResultSet(ResultSet rs)
		throws SQLException
	{
		RankListBean rankListBean = new RankListBean();
		rankListBean.setRank_id( (rs.getInt("rank_id") ) );
		rankListBean.setRank_name( (rs.getString("rank_name") ) );
		rankListBean.setTotal_days( (rs.getInt("total_days") ) );
		rankListBean.setTotalEmployees( (rs.getInt("totalemployees") ) );
		return rankListBean;
	}
	
	@Override
	public ArrayList<RankListBean> findAllRankList()
		throws SQLException, ClassNotFoundException
	{
		String query = "select r.rank_id, r.rank_name, r.total_days, count(e.employee_id) AS totalemployees from rank_tb r left outer join employee_tb e on r.rank_id=e.rank_id group by r.rank_id, r.rank_name, r.total_days";
		return (executeMultipleQuery(query) );		
	}
}
